﻿using System.Collections.Specialized;
using System.IO;

namespace smarx.HostedWebCore
{
    public static class WorkerConfig
    {
        public static string SubstituteParameters(NameValueCollection parameters, string input)
        {
            string output = input;
            foreach (var parameter in parameters.AllKeys)
            {
                output = output.Replace("{" + parameter + "}", parameters[parameter]);
            }
            return output;
        }

        public static void WriteConfigFile(NameValueCollection parameters, string inPath, string outPath)
        {
            File.WriteAllText(outPath, SubstituteParameters(parameters, File.ReadAllText(inPath)));
        }
    }
}